package com.songshuai.customer.client.service.impl;

import com.songshuai.customer.client.dao.customer.CustomerInfoMapper;
import com.songshuai.customer.client.service.CustomerInfoService;
import com.songshuai.webapi.baseapi.model.sales.CustomerInfo;

import com.songshuai.webapi.baseapi.utils.SnowFlakeUtil;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;


/**
 * 此类为[基础代码]自动生成,已经拥有基本的增删改成操作 
 * <其他请自行扩展>
 * @Author: 刘汉轩
 * @Date: 2019-03-18 16:48:27
 * 
 */
@Service
public class CustomerInfoServiceImpl implements CustomerInfoService {
 
      
    @Autowired
	private CustomerInfoMapper customerInfoMapper;

    @Autowired
    private SnowFlakeUtil snowFlakeUtil;
	
	
	/**
     * 新增
     * @param entity 
     */
    public int insertSelective (CustomerInfo entity) {
        entity.setId(snowFlakeUtil.nextId());
        entity.setCreateTime(new Date());
        return this.customerInfoMapper.insertSelective(entity);
    }	
    
    /**
     * 批量新增
     * @param list 
     */
    public void insertBatch(List<CustomerInfo> list) {       
        this.customerInfoMapper.insertBatch(list); 
    }
    
    /**
     * 根据主键修改单条数据
     * @param entity 
     */
    public int updateByPrimaryKey(CustomerInfo entity) {
        return this.customerInfoMapper.updateByPrimaryKey(entity);
    }
    
    /**
     * 根据主键批量修改数据
     * @param list 
     */
    public void updateBatch(List<CustomerInfo> list) {      
        this.customerInfoMapper.updateBatch(list);     
    }
    
    /**
     * 根据主键查询单条数据
     * @param id
     */
    public CustomerInfo selectByPrimaryKey(String id) {
        return this.customerInfoMapper.selectByPrimaryKey(id);
    }
    
    /**
     * 根据条件查询单条记录
     * @param entity 
     */
    public CustomerInfo selectByEntity(CustomerInfo entity) {
        return this.customerInfoMapper.selectByEntity(entity);
    }
      
    /**
     * 根据条件查询多条记录
     * @param entity 
     */
    public List<CustomerInfo> selectByEntityList(CustomerInfo entity) {
        return this.customerInfoMapper.selectByEntityList(entity);
    }
    
    /**
     * 根据条件查询Id
     * @param entity 
     */
    public String selectById(CustomerInfo entity) {
        return this.customerInfoMapper.selectById(entity);
    }
    
    /**
     * 根据条件查询Ids
     * @param entity 
     */
    public List<String> selectByIds(CustomerInfo entity) {
        return this.customerInfoMapper.selectByIds(entity);
    }
    
    /**
     * 根据主键删除单条记录
     * @param id
     */
    public void deleteByPrimaryKey(String id) {
        this.customerInfoMapper.deleteByPrimaryKey(id);
    }
    
    /**
     * 根据主键删除多条记录
     * @param list
     */
    public void deleteBatch(List<String> list) {
        this.customerInfoMapper.deleteBatch(list);
    }
    
    /**
     * 根据某些条件删除
     * @param entity
     */
    public void deleteByEntity(CustomerInfo entity) {
        this.customerInfoMapper.deleteByEntity(entity);
    }

    @Override
    public void updateByOpenId(CustomerInfo entity) {
        customerInfoMapper.updateByOpenId(entity);
    }


}